package com.seocoo.worker.friend;

import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;

import com.flyco.tablayout.SlidingTabLayout;
import com.flyco.tablayout.listener.OnTabSelectListener;
import com.seocoo.worker.R;
import com.seocoo.worker.base.UtilStatus;
import com.sfh.lib.ui.MVVMActivity;

import java.util.ArrayList;

/**
 * author : Ssp
 * e-mail : 981297079@qq.com
 * date   : 2020/3/719:49
 * desc   : 我的评价
 * version: 1.0
 */
public class FriendAppraiseActivity extends MVVMActivity {

    private final String[] mTitles = {"用户评价", "工友评价"};

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.friend_appraise_activity);
        UtilStatus.initStatus(this, Color.WHITE);

        SlidingTabLayout tabLayout1 = findViewById(R.id.tab_layout1);
        ViewPager viewPager = findViewById(R.id.viwepager1);
        ArrayList<Fragment> list = new ArrayList<>();
        Fragment fragment1 = FriendAppraiseFragment.newInstance("1");
        list.add(fragment1);
        Fragment fragment2 = FriendAppraiseFragment.newInstance("2");
        list.add(fragment2);
        tabLayout1.setViewPager(viewPager, mTitles, this, list);
        tabLayout1.setOnTabSelectListener(new OnTabSelectListener() {
            @Override
            public void onTabSelect(int position) {
                FriendAppraiseFragment fragment = (FriendAppraiseFragment) list.get(position);
                if (fragment != null) {
                    fragment.reFreshData();
                }
            }

            @Override
            public void onTabReselect(int position) {

            }
        });
        viewPager.setCurrentItem(0);
    }

    public static void start(Context context) {
        context.startActivity(new Intent(context, FriendAppraiseActivity.class));
    }
}
